<template>
  <el-container class="panel-container">
    <el-tabs
      v-model="activeTab"
      style="height: 100%; overflow: hidden; width: 100%"
    >
      <el-tab-pane label="属性" name="1">
        <el-scrollbar
          class="setting-scrollbar"
          :style="{ height: scrollerHeight }"
        >
          <template
            v-if="
              !!designer.selectedWidget &&
              Object.keys(designer.selectedWidget).length > 0
            "
          >
         
            <template v-if="!designer.selectedWidget.category">
              <el-form
                :model="optionModel"
                size="mini"
                label-position="left"
                label-width="120px"
                class="setting-form"
                @submit.native.prevent
              >
                <el-collapse
                  v-model="widgetActiveCollapseNames"
                  class="setting-collapse"
                >
                  <el-collapse-item
                    name="1"
                    v-if="showCollapse(commonProps)"
                    :title="i18nt('designer.setting.commonSetting')"
                  >
                    <template v-for="(editorName, propName) in commonProps">
                      <component
                        v-if="hasPropEditor(propName, editorName)"
                        :is="getPropEditor(propName, editorName)"
                        :designer="designer"
                        :selected-widget="selectedWidget"
                        :option-model="optionModel"
                      ></component>
                    </template>
                  </el-collapse-item>

                  <el-collapse-item
                    name="2"
                    v-if="showCollapse(advProps)"
                    :title="i18nt('designer.setting.advancedSetting')"
                  >
                    <template v-for="(editorName, propName) in advProps">
                      <component
                        v-if="hasPropEditor(propName, editorName)"
                        :is="getPropEditor(propName, editorName)"
                        :designer="designer"
                        :selected-widget="selectedWidget"
                        :option-model="optionModel"
                      ></component>
                    </template>
                  </el-collapse-item>
                </el-collapse>
              </el-form>
            </template>
            <template v-if="!!designer.selectedWidget.category">
              <el-form
                :model="optionModel"
                size="mini"
                label-position="left"
                label-width="120px"
                class="setting-form"
                @submit.native.prevent
              >
                <el-collapse
                  v-model="widgetActiveCollapseNames"
                  class="setting-collapse"
                >
                  <el-collapse-item
                    name="1"
                    v-if="showCollapse(commonProps)"
                    :title="i18nt('designer.setting.commonSetting')"
                  >
                    <template v-for="(editorName, propName) in commonProps">
                      <component
                        v-if="hasPropEditor(propName, editorName)"
                        :is="getPropEditor(propName, editorName)"
                        :designer="designer"
                        :selected-widget="selectedWidget"
                        :option-model="optionModel"
                      ></component>
                    </template>
                  </el-collapse-item>
                  <el-collapse-item
                    name="2"
                    v-if="showCollapse(advProps)"
                    :title="i18nt('designer.setting.advancedSetting')"
                  >
                    <template v-for="(editorName, propName) in advProps">
                      <component
                        v-if="hasPropEditor(propName, editorName)"
                        :is="getPropEditor(propName, editorName)"
                        :designer="designer"
                        :selected-widget="selectedWidget"
                        :option-model="optionModel"
                      ></component>
                    </template>
                  </el-collapse-item>
                </el-collapse>
              </el-form>
            </template>
          </template>

          <template v-else>
            <el-scrollbar
              class="setting-scrollbar"
              :style="{ height: scrollerHeight }"
            >
              <form-setting
                showTemp="form"
                :designer="designer"
                :form-config="formConfig"
              ></form-setting>
            </el-scrollbar>
          </template>
        </el-scrollbar>
      </el-tab-pane>
      <el-tab-pane label="事件" name="2">
        <template
          v-if="
            !!designer.selectedWidget &&
            Object.keys(designer.selectedWidget).length > 0
          "
        >
          <template v-if="!designer.selectedWidget.category">
            <el-form
              :model="optionModel"
              size="mini"
              label-position="left"
              label-width="120px"
              class="setting-form"
              @submit.native.prevent
            >
              <el-collapse
                v-model="widgetActiveCollapseNames"
                class="setting-collapse"
              >
                <el-collapse-item
                  name="3"
                  v-if="showEventCollapse() && showCollapse(eventProps)"
                  :title="i18nt('designer.setting.eventSetting')"
                >
                  <template v-for="(editorName, propName) in eventProps">
                    <component
                      v-if="hasPropEditor(propName, editorName)"
                      :is="getPropEditor(propName, editorName)"
                      :designer="designer"
                      :rowData="rowData"
                      :selected-widget="selectedWidget"
                      :option-model="optionModel"
                    ></component>
                  </template>
                </el-collapse-item>
              </el-collapse>
            </el-form>
          </template>

          <template v-if="!!designer.selectedWidget.category">
            <el-form
              :model="optionModel"
              size="mini"
              label-position="left"
              label-width="120px"
              class="setting-form"
              @submit.native.prevent
            >
              <el-collapse
                v-model="widgetActiveCollapseNames"
                class="setting-collapse"
              >
                <el-collapse-item
                  name="3"
                  v-if="showEventCollapse() && showCollapse(eventProps)"
                  :title="i18nt('designer.setting.eventSetting')"
                >
                  <template v-for="(editorName, propName) in eventProps">
                    <component
                      v-if="hasPropEditor(propName, editorName)"
                      :is="getPropEditor(propName, editorName)"
                      :designer="designer"
                      :selected-widget="selectedWidget"
                      :option-model="optionModel"
                    ></component>
                  </template>
                </el-collapse-item>
              </el-collapse>
            </el-form>
          </template>
        </template>

        <template v-else>
          <el-scrollbar
            class="setting-scrollbar"
            :style="{ height: scrollerHeight }"
          >
            <form-setting
              showTemp="methods"
              :designer="designer"
              :form-config="formConfig"
            ></form-setting>
          </el-scrollbar>
        </template>
      </el-tab-pane>
      <el-tab-pane label="数据源" name="3">
        <p>
          <el-button size="mini" @click="addDataSource">添加数据源</el-button>
        </p>
        <div class="list">
          <template v-for="(item, idx) in designer.dataSource">
            <div
              class="list-item"
              :class="{ activeDataSource: formIdx === idx }"
              :key="idx"
              @click.prevent.stop="editDataSource(item, idx)"
            >
              <div>
                <el-tag>{{ item.name }}</el-tag>
                <div
                  style="font-size: 12px; margin-top: 10px; text-indent: 10px"
                >
                  描述：
                  {{ item.remark }}
                </div>
              </div>
              <div class="list-item-operation">
                <el-button
                  type="text"
                  icon="el-icon-delete"
                  @click.prevent.stop="delDataSource(idx)"
                ></el-button>
              </div>
            </div>
          </template>
        </div>
      </el-tab-pane>
      <el-tab-pane label="脚本" name="4">
        <p>
          <el-button
            size="mini"
            type="primary"
            @click="(funVisible = true), (funDialog = 'add')"
          >
            添加方法
          </el-button>
        </p>

        <div
          :class="{ active: activeScript === 'data' }"
          class="dsd-item"
          @click="edit('data')"
        >
          data
        </div>
        <el-collapse :value="[1]">
          <el-collapse-item :name="1" title="methods">
            <template v-for="(it, ix) in pageScript.methods">
              <div
                :class="{ active: activeScript === it.funName }"
                class="dsd-item dsdContent"
                :key="ix"
                @click="edit(it.funName)"
              >
                <div class="dsdDetail">
                  {{ it.funName }}
                  <span style="font-size: 12px">
                    （{{ it.funRemark ? it.funRemark : "-" }}）
                  </span>
                </div>
                <div class="after-btn">
                  <el-button
                    type="text"
                    icon="el-icon-edit-outline"
                  ></el-button>
                  <el-button type="text" icon="el-icon-delete"></el-button>
                </div>
              </div>
            </template>
          </el-collapse-item>
        </el-collapse>
        <div
          :class="{ active: activeScript === 'mounted' }"
          class="dsd-item"
          @click="edit('mounted')"
        >
          mounted
        </div>
        <div
          :class="{ active: activeScript === 'created' }"
          class="dsd-item"
          @click="edit('created')"
        >
          created
        </div>
      </el-tab-pane>
    </el-tabs>
    <div class="widgetTreeBox">
      <div
        class="boxItem controlBox"
        v-if="initTreeData.length > 4"
        @click="showAll"
      >
        <i
          class="el-icon-arrow-right"
          v-if="initTreeData.length === widgetTreeData.length"
        />
        <i class="el-icon-arrow-left" v-else />
      </div>
      <div
        v-for="(item, index) in widgetTreeData"
        :key="item.id"
        class="boxItem"
      >
        <div
          class="boxItemContent"
          :class="{
            activeItem: index === widgetTreeData.length - 1,
            activeItemBefore: index === widgetTreeData.length - 2,
          }"
          @click="selectItem(item)"
        >
          <!-- <span class="leftWrap" v-if="index !==0"></span> -->
          <div class="boxItemText">{{ item.type }}</div>
          <span class="rightWrap" v-if="widgetTreeData.length - index >2">
            <span class="rightWrapArrow"></span>
          </span>
          <span class="rightWrap" v-else></span>
          
        </div>
      </div>
    </div>

    <el-dialog
      :title="i18nt('designer.setting.editWidgetEventHandler')"
      :visible.sync="showWidgetEventDialogFlag"
      v-if="showWidgetEventDialogFlag"
      :show-close="true"
      class="small-padding-dialog"
      append-to-body
      v-dialog-drag
      :close-on-click-modal="false"
      :close-on-press-escape="false"
      :destroy-on-close="true"
    >
      <el-alert type="info" :closable="false" :title="eventHeader"></el-alert>
      <code-editor
        :mode="'javascript'"
        :readonly="false"
        v-model="eventHandlerCode"
        ref="ecEditor"
      ></code-editor>
      <el-alert type="info" :closable="false" title="}"></el-alert>
      <div slot="footer" class="dialog-footer">
        <el-button @click="showWidgetEventDialogFlag = false">
          {{ i18nt("designer.hint.cancel") }}
        </el-button>
        <el-button type="primary" @click="saveEventHandler">
          {{ i18nt("designer.hint.confirm") }}
        </el-button>
      </div>
    </el-dialog>

    <el-dialog
      width="450px"
      title="方法"
      :visible.sync="funVisible"
      :modal-append-to-body="true"
      :destroy-on-close="true"
      :append-to-body="true"
    >
      <el-form
        size="mini"
        ref="fs"
        :model="formScript"
        :rules="rulesScript"
        label-width="65px"
      >
        <el-form-item label="方法名" prop="funName">
          <el-input v-model="formScript.funName"></el-input>
        </el-form-item>
        <el-form-item label="备注">
          <el-input v-model="formScript.funRemark"></el-input>
        </el-form-item>
      </el-form>
      <div slot="footer" style="text-align: right">
        <el-button size="mini" type="primary" @click="addMethods"
          >确定</el-button
        >
        <el-button size="mini" @click="closeMethods">取消</el-button>
      </div>
    </el-dialog>
    <!--编辑脚本-->
    <script-edit
      ref="scriptEdit"
      :type="tabType"
      :scriptType="activeScript"
      :designer.sync="designer"
      :visible.sync="scriptEditVisible"
    ></script-edit>
  </el-container>
</template>

<script>
import CodeEditor from "@/components/code-editor/index";
import PropertyEditors from "./property-editor/index";
import FormSetting from "./form-setting";
import WidgetProperties from "./propertyRegister";
import { addWindowResizeHandler } from "@/utils/util";
import i18n from "@/utils/i18n";
import { propertyRegistered } from "@/components/form-designer/setting-panel/propertyRegister";
import ScriptEdit from "@/components/form-designer/setting-panel/scriptEdit.vue";
import * as api from "@/api/applicationManage/applicationManage";

const { COMMON_PROPERTIES, ADVANCED_PROPERTIES, EVENT_PROPERTIES } =
  WidgetProperties;

export default {
  name: "SettingPanel",
  componentName: "SettingPanel",
  mixins: [i18n],
  components: {
    ScriptEdit,
    CodeEditor,
    FormSetting,
    ...PropertyEditors,
  },
  props: {
    designer: Object,
    selectedWidget: Object,
    rowData: Object,
    formConfig: Object,
    globalDsv: {
      type: Object,
      default: () => ({}),
    },
  },
  provide() {
    return {
      isSubFormChildWidget: () => this.subFormChildWidgetFlag,
    };
  },
  inject: ["getDesignerConfig"],
  data() {
    return {
      designerConfig: this.getDesignerConfig(),
      widgetTreeData: [],
      initTreeData: [],
      scrollerHeight: 0,

      activeTab: "1",
      widgetActiveCollapseNames: ["1", "3"], //['1', '2', '3'],
      formActiveCollapseNames: ["1", "2"],

      commonProps: COMMON_PROPERTIES,
      advProps: ADVANCED_PROPERTIES,
      eventProps: EVENT_PROPERTIES,

      showWidgetEventDialogFlag: false,
      eventHandlerCode: "",
      curEventName: "",
      eventHeader: "",

      subFormChildWidgetFlag: false,
      funVisible: false,
      funDialog: "add",
      formScript: {
        funName: "",
        funBody: "",
        funRemark: "",
        id: "",
      },
      scriptEditVisible: false,
      tabType: "",
      activeScript: "data",
    };
  },
  computed: {
    optionModel: {
      get() {
        return this.selectedWidget.options;
      },

      set(newValue) {
        this.selectedWidget.options = newValue;
      },
    },
    pageScript() {
      return this.designer.pageScript;
    },
  },
  watch: {
    "designer.selectedWidget": {
      handler(val) {
        if (val && val.id) {
          this.activeTab = "1";
          this.getWidgetTree(val.id);
        } else {
          this.widgetTreeData = [];
        }
      },
    },

    "selectedWidget.options": {
      //组件属性变动后，立即保存表单JSON！！
      deep: true,
      handler() {
        this.designer.saveCurrentHistoryStep();
      },
    },

    formConfig: {
      deep: true,
      handler() {
        this.designer.saveCurrentHistoryStep();
      },
    },
  },
  created() {
    this.$on("editEventHandler", function (eventName, eventParams) {
      this.editEventHandler(eventName, eventParams);
    });

    this.designer.handleEvent("form-css-updated", (cssClassList) => {
      this.designer.setCssClassList(cssClassList);
    });

    //监听字段组件选中事件
    this.designer.handleEvent("field-selected", (parentWidget) => {
      this.subFormChildWidgetFlag =
        !!parentWidget && parentWidget.type === "sub-form";
    });
  },
  mounted() {
    this.activeTab = "1";
    this.scrollerHeight = window.innerHeight - 56 - 48 + "px";
    addWindowResizeHandler(() => {
      this.$nextTick(() => {
        this.scrollerHeight = window.innerHeight - 56 - 48 + "px";
      });
    });
  },
  methods: {
    selectItem(data) {
      if (data.id === "init") {
        this.designer.selectedWidget = {};
      } else {
        this.designer.setSelected(data);
      }
    },
    flatten(tree = [], arr = [], parentId = "") {
      tree.forEach((item) => {
        const children = item.cols || item.widgetList;
        if (parentId) {
          arr.push({ ...item, parentId });
        } else {
          arr.push(item);
        }
        children && this.flatten(children, arr, item.id);
      });
      return arr;
    },

    findParents(treeData, id) {
      let allParents = [];
      if (treeData.length == 0) {
        return [];
      }

      let findEle = (data, id) => {
        if (!id) return;
        data.forEach((item, index) => {
          if (item.id === id) {
            allParents.unshift({ ...item });
            findEle(treeData, item.parentId);
          }
        });
      };

      findEle(treeData, id);
      return allParents;
    },
    showAll() {
      if (this.initTreeData.length === this.widgetTreeData.length) {
        this.widgetTreeData = this.initTreeData.slice(
          this.initTreeData.length - 4
        );
      } else {
        this.widgetTreeData = [...this.initTreeData];
      }
    },
    getWidgetTree(id) {
      const widgetList = this.designer.widgetList;
      const flattenData = this.flatten(widgetList);
      const selectedDataTree = this.findParents(flattenData, id);
      this.initTreeData = [{ type: "Page", id: "init" }, ...selectedDataTree];
      if (selectedDataTree.length > 3) {
        this.widgetTreeData = selectedDataTree.slice(
          selectedDataTree.length - 4
        );
      } else {
        this.widgetTreeData = [
          { type: "Page", id: "init" },
          ...selectedDataTree,
        ];
      }
    },
    delDataSource(idx) {
      this.designer.dataSource.splice(idx, 1);
    },
    getOidByType(data) {
      let oid = data.oid;
      // originType 1 2 url 3 oid
      if (data.originType && [1, 2].indexOf(data.originType) > -1) {
        oid = data.url;
      }
      return oid;
    },
    editDataSource(item, idx) {
      this.tabType = "data";
      this.scriptEditVisible = true;
      this.$nextTick(() => {
        this.$refs.scriptEdit &&
          this.$refs.scriptEdit.editDataSource(item, idx);
      });
    },
    edit(type) {
      this.scriptEditVisible = true;
      this.tabType = "script";
      this.activeScript = type;
    },
    addMethods() {
      this.$refs["fs"].validate((f) => {
        if (f) {
          if (this.funDialog === "add") {
            this.formScript.id = this.getOnlyId();
            this.pageScript.methods.push(this.formScript);
          }
          if (this.funDialog === "edit") {
            let index = this.pageScript.methods
              .map((i) => i.id)
              .indexOf(this.formScript.id);
            this.pageScript.methods[index] = this.deepCopy(this.formScript);
          }

          this.closeMethods();
        }
      });
    },
    closeMethods() {
      this.funVisible = false;
      this.formScript = {
        funName: "",
        funBody: "",
        funRemark: "",
        id: "",
      };
    },
    addDataSource() {
      this.scriptEditVisible = true;
      this.tabType = "data";
    },
    showEventCollapse() {
      if (this.designerConfig["eventCollapse"] === undefined) {
        return true;
      }

      return !!this.designerConfig["eventCollapse"];
    },

    hasPropEditor(propName, editorName) {
      if (!editorName) {
        return false;
      }

      /* alert组件注册了两个type属性编辑器，跳过第一个type属性编辑器，只显示第二个alert-type属性编辑器！！ */
      if (propName.indexOf("-") <= -1) {
        let uniquePropName = this.selectedWidget.type + "-" + propName;
        if (propertyRegistered(uniquePropName)) {
          return false;
        }
      }

      let originalPropName = propName.replace(
        this.selectedWidget.type + "-",
        ""
      ); //去掉组件名称前缀-，如果有的话！！
      
      return this.designer.hasConfig(this.selectedWidget, originalPropName);
    },

    getPropEditor(propName, editorName) {
      let originalPropName = propName.replace(
        this.selectedWidget.type + "-",
        ""
      ); //去掉组件名称前缀-，如果有的话！！
      if(this.selectedWidget.type === 'operate-button'){
        let ownPropEditorName = `button-${originalPropName}-editor`;
        if (this.$options.components[ownPropEditorName]) {
          //局部注册的属性编辑器组件
          return ownPropEditorName;
        }
      }
      let ownPropEditorName = `${this.selectedWidget.type}-${originalPropName}-editor`;
      if (this.$options.components[ownPropEditorName]) {
        //局部注册的属性编辑器组件
        return ownPropEditorName;
      }

      return this.$root.$options.components[ownPropEditorName]
        ? ownPropEditorName
        : editorName; //全局注册的属性编辑器组件
    },

    showCollapse(propsObj) {
      let result = false;

      for (let propName in propsObj) {
        if (!propsObj.hasOwnProperty(propName)) {
          continue;
        }

        if (this.hasPropEditor(propName, propsObj[propName])) {
          result = true;
          break;
        }
      }

      return result;
    },

    editEventHandler(eventName, eventParams) {
      this.curEventName = eventName;
      this.eventHeader = `${
        this.optionModel.name
      }.${eventName}(${eventParams.join(", ")}) {`;
      this.eventHandlerCode = this.selectedWidget.options[eventName] || "";

      // 设置字段校验函数示例代码
      if (eventName === "onValidate" && !this.optionModel["onValidate"]) {
        this.eventHandlerCode =
          "  /* sample code */\n  /*\n  if ((value > 100) || (value < 0)) {\n    callback(new Error('error message'))  //fail\n  } else {\n    callback();  //pass\n  }\n  */";
      }

      this.showWidgetEventDialogFlag = true;
    },

    saveEventHandler() {
      const codeHints = this.$refs.ecEditor.getEditorAnnotations();
      let syntaxErrorFlag = false;
      if (!!codeHints && codeHints.length > 0) {
        codeHints.forEach((chItem) => {
          if (chItem.type === "error") {
            syntaxErrorFlag = true;
          }
        });

        if (syntaxErrorFlag) {
          this.$message.error(
            this.i18nt("designer.setting.syntaxCheckWarning")
          );
          return;
        }
      }

      this.selectedWidget.options[this.curEventName] = this.eventHandlerCode;
      this.showWidgetEventDialogFlag = false;
    },
  },
};
</script>

<style lang="scss" scoped>
.panel-container {
  padding: 0 8px;
  position: relative;
  min-height: 90%;
}
.widgetTreeBox {
  position: absolute;
  bottom: -50px;
  left: 0;
  display: flex;
  width: 100%;
  overflow-y: scroll;
  flex-wrap: nowrap;
  background-color: #f2f2f2;
  &::-webkit-scrollbar {
    width: 0px;
    height: 0;
  }
  .boxItem {
    display: flex;
    height: 30px;
    justify-content: center;
    align-items: center;
    line-height: 30px;
    background-color: #f2f2f2;
    .boxItemContent {
      // padding: 0 10px;
      white-space: nowrap;
      cursor: pointer;
      height: 30px;
      line-height: 30px;
      position: relative;
      .boxItemText {
        padding: 0 10px 0 15px;
      }
      .rightWrapArrow{
         position: absolute;
          right: 2px;
          top: -15px;
          display: block;
          border-top: 16px solid transparent;
          border-bottom: 16px solid transparent;
          border-right: 0 solid transparent;
          border-left: 16px solid #f2f2f2;
      }
      &.activeItem {
        // color: #1e9fff !important;
        background-color: #1e9fff;
        color: #fff;
        .rightWrap {
          position: absolute;
           right: -10px;
          top: 0;
          display: block;
          border-top: 16px solid #f2f2f2;
          border-bottom: 16px solid #f2f2f2;
          border-right: 0 solid #f2f2f2;
          border-left: 16px solid #1e9fff;
        }
      }
      &.activeItemBefore {
        .rightWrap {
          position: absolute;
          right: -10px;
          top: 0;
          display: block;
          border-top: 16px solid #1e9fff;
          border-bottom: 16px solid #1e9fff;
          border-right: 0 solid #1e9fff;
          border-left: 16px solid #f2f2f2;
        }
      }
      .rightWrap {
        position: absolute;
         right: -10px;
        top: 0;
        display: block;
        border-top: 16px solid #f2f2f2;
        border-bottom: 16px solid #f2f2f2;
        border-right: 0 solid #f2f2f2;
        border-left: 16px solid #ccc;
        z-index: 999;
        
      }
    }
  }
  .controlBox {
    background: #ccc;
    color: #fff;
    cursor: pointer;
  }
}

.setting-scrollbar {
  ::v-deep .el-scrollbar__wrap {
    overflow-x: hidden; /* IE浏览器隐藏水平滚动条箭头！！ */
  }

  ::v-deep .el-scrollbar__bar {
    width: 0;
    height: 0;
  }
}

.setting-collapse {
  ::v-deep .el-collapse-item__content {
    padding-bottom: 6px;
  }

  ::v-deep .el-collapse-item__header {
    font-style: italic;
    font-weight: bold;
  }
}

.setting-form {
  ::v-deep .el-form-item__label {
    font-size: 13px;
    //text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }

  ::v-deep .el-form-item--mini.el-form-item {
    margin-bottom: 6px;
  }
}

/* 隐藏Chrome浏览器中el-input数字输入框右侧的上下调整小箭头 */
::v-deep .hide-spin-button input::-webkit-outer-spin-button,
::v-deep .hide-spin-button input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
}

/* 隐藏Firefox浏览器中el-input数字输入框右侧的上下调整小箭头 */
::v-deep .hide-spin-button input[type="number"] {
  -moz-appearance: textfield;
}

::v-deep .custom-divider.el-divider--horizontal {
  margin: 10px 0;
}

::v-deep .custom-divider-margin-top.el-divider--horizontal {
  margin: 20px 0;
}

.small-padding-dialog {
  ::v-deep .el-dialog__body {
    padding: 6px 15px 12px 15px;
  }
}
.list {
  width: 100%;
  height: calc(100% - 40px);
  margin-top: 10px;

  .list-item {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 5px 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    flex-wrap: nowrap;
    margin-bottom: 5px;
    cursor: pointer;

    .list-item-operation {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      flex-wrap: nowrap;

      .el-button {
        padding: 0;
      }
    }
  }

  .activeDataSource {
    background: rgba(242, 242, 242, 0.5);
    border: 1px solid #1e9fff;
  }
}
.dsd-item {
  height: 30px;
  line-height: 30px;
  padding-left: 10px;
  font-size: 14px;
  cursor: pointer;
  position: relative;

  &:hover {
    background: rgba(242, 242, 242, 0.5);
  }

  .after-btn {
    position: absolute;
    height: 30px;
    top: 0;
    right: 10px;
    ::v-deep .el-button--text {
      padding: 0;
    }
  }
}
.dsdContent {
  width: 100%;
  box-sizing: border-box;
  padding-right: 80px;
  .dsdDetail {
    width: 100%;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
}

::v-deep .el-tabs {
  width: 100%;
  height: 100%;

  .el-collapse {
    border: none;

    .el-collapse-item {
      > div {
        border: none;

        .el-collapse-item__header {
          height: 30px;
          line-height: 30px;
          padding-left: 10px;
          border: none;
          background: #f2f2f2;
          color: #606266;
        }

        .el-collapse-item__content {
          padding-bottom: 0;
          padding-left: 15px;
          box-sizing: border-box;
        }
      }
    }
  }
}
.active {
  background: #1e9fff !important;
  color: white;
}
</style>
